package com.bsoft.mob.deviceinfo;

import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.util.DisplayMetrics;
import android.widget.TextView;

import java.io.File;
import java.io.IOException;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TextView id_dev = (TextView) findViewById(R.id.id_dev);
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("设备厂商MANUFACTURER:");
        stringBuilder.append(Build.MANUFACTURER);
        stringBuilder.append("\n\n");

        stringBuilder.append("设备型号MODEL:");
        stringBuilder.append(Build.MODEL);
        stringBuilder.append("\n\n");

        stringBuilder.append("品牌BRAND:");
        stringBuilder.append(Build.BRAND);
        stringBuilder.append("\n\n");

        stringBuilder.append("主板BOARD:");
        stringBuilder.append(Build.BOARD);
        stringBuilder.append("\n\n");

        stringBuilder.append("产品PRODUCT:");
        stringBuilder.append(Build.PRODUCT);
        stringBuilder.append("\n\n");

        stringBuilder.append("ID:");
        stringBuilder.append(Build.ID);
        stringBuilder.append("\n\n");

        stringBuilder.append("显示DISPLAY:");
        stringBuilder.append(Build.DISPLAY);
        stringBuilder.append("\n\n");

        stringBuilder.append("设备DEVICE:");
        stringBuilder.append(Build.DEVICE);
        stringBuilder.append("\n\n");

        stringBuilder.append("引导程序BOOTLOADER:");
        stringBuilder.append(Build.BOOTLOADER);
        stringBuilder.append("\n\n");

        stringBuilder.append("无线电版本getRadioVersion:");
        stringBuilder.append(Build.getRadioVersion());
        stringBuilder.append("\n\n");

        stringBuilder.append("硬件HARDWARE:");
        stringBuilder.append(Build.HARDWARE);
        stringBuilder.append("\n\n");


        stringBuilder.append("版本增量VERSION INCREMENTAL:");
        stringBuilder.append(Build.VERSION.INCREMENTAL);
        stringBuilder.append("\n\n");

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {


            stringBuilder.append("安全补丁VERSION SECURITY_PATCH:");
            stringBuilder.append(Build.VERSION.SECURITY_PATCH);
            stringBuilder.append("\n\n");

            stringBuilder.append("VERSION BASE_OS:");
            stringBuilder.append(Build.VERSION.BASE_OS);
            stringBuilder.append("\n\n");


            stringBuilder.append("VERSION_CODES CUR_DEVELOPMENT:");
            stringBuilder.append(Build.VERSION_CODES.CUR_DEVELOPMENT);
            stringBuilder.append("\n\n");


            stringBuilder.append("VERSION PREVIEW_SDK_INT:");
            stringBuilder.append(Build.VERSION.PREVIEW_SDK_INT);
            stringBuilder.append("\n\n");
        }


        stringBuilder.append("代号VERSION CODENAME:");
        stringBuilder.append(Build.VERSION.CODENAME);
        stringBuilder.append("\n\n");

        stringBuilder.append("发行VERSION RELEASE:");
        stringBuilder.append(Build.VERSION.RELEASE);
        stringBuilder.append("\n\n");

        stringBuilder.append("VERSION SDK_INT:");
        stringBuilder.append(Build.VERSION.SDK_INT);
        stringBuilder.append("\n\n");

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            stringBuilder.append("SUPPORTED_ABIS:");
            for (String supportedAbi : Build.SUPPORTED_ABIS) {
                stringBuilder.append(supportedAbi + " ");
            }
            stringBuilder.append("\n\n");
            stringBuilder.append("SUPPORTED_32_BIT_ABIS:");
            for (String supportedAbi : Build.SUPPORTED_32_BIT_ABIS) {
                stringBuilder.append(supportedAbi + " ");
            }
            stringBuilder.append("\n\n");
            stringBuilder.append("SUPPORTED_64_BIT_ABIS:");
            for (String supportedAbi : Build.SUPPORTED_64_BIT_ABIS) {
                stringBuilder.append(supportedAbi + " ");
            }
            stringBuilder.append("\n\n");
        } else {
            stringBuilder.append("CPU_ABI:");
            stringBuilder.append(Build.CPU_ABI);
            stringBuilder.append("\n\n");
            stringBuilder.append("CPU_ABI2:");
            stringBuilder.append(Build.CPU_ABI2);
            stringBuilder.append("\n\n");
        }

        stringBuilder.append("getSerial:");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            stringBuilder.append(Build.getSerial());
            stringBuilder.append("\n\n");
        } else {
            stringBuilder.append(Build.SERIAL);
            stringBuilder.append("\n\n");
        }

        stringBuilder.append("HOST:");
        stringBuilder.append(Build.HOST);
        stringBuilder.append("\n\n");

        stringBuilder.append("时间TIME:");
        stringBuilder.append(Build.TIME);
        stringBuilder.append("\n\n");

        stringBuilder.append("用户USER:");
        stringBuilder.append(Build.USER);
        stringBuilder.append("\n\n");

        stringBuilder.append("标签TAGS:");
        stringBuilder.append(Build.TAGS);
        stringBuilder.append("\n\n");

        stringBuilder.append("类型TYPE:");
        stringBuilder.append(Build.TYPE);
        stringBuilder.append("\n\n");

        stringBuilder.append("指纹FINGERPRINT:");
        stringBuilder.append(Build.FINGERPRINT);
        stringBuilder.append("\n\n");
        stringBuilder.append("\n\n");

        DisplayMetrics displayMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        int width = displayMetrics.widthPixels;
        int height = displayMetrics.heightPixels;
        stringBuilder.append("分辨率");
        stringBuilder.append(width);
        stringBuilder.append("px * ");
        stringBuilder.append(height);
        stringBuilder.append("px\n");
        stringBuilder.append("密度density:");
        stringBuilder.append(displayMetrics.density);
        stringBuilder.append("\n\n");
        stringBuilder.append("像素每英寸densityDpi:");
        stringBuilder.append(displayMetrics.densityDpi);
        stringBuilder.append(" dpi\n");
        stringBuilder.append("缩放密度scaledDensity:");
        stringBuilder.append(displayMetrics.scaledDensity);
        stringBuilder.append("\n\n");
        stringBuilder.append("xdpi:");
        stringBuilder.append(displayMetrics.xdpi);
        stringBuilder.append("\n\n");
        stringBuilder.append("ydpi:");
        stringBuilder.append(displayMetrics.ydpi);
        stringBuilder.append("\n\n");

        stringBuilder.append("======================");
        stringBuilder.append("\n\n");


        //  /storage/sdcard0/Alarms
        String DIRECTORY_ALARMS_getParent = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS).getParent();
        File DIRECTORY_ALARMS_getParentFile = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS).getParentFile();
        String DIRECTORY_ALARMS_getName = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS).getName();
        stringBuilder.append("DIRECTORY_ALARMS_getParent\n");
        stringBuilder.append(DIRECTORY_ALARMS_getParent);
        stringBuilder.append("\n\n");

        stringBuilder.append("DIRECTORY_ALARMS_getParentFile\n");
        stringBuilder.append(DIRECTORY_ALARMS_getParentFile.getAbsolutePath());
        stringBuilder.append("\n\n");

        stringBuilder.append("DIRECTORY_ALARMS_getName\n");
        stringBuilder.append(DIRECTORY_ALARMS_getName);
        stringBuilder.append("\n\n");


        String DIRECTORY_ALARMS_getAbsolutePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS).getAbsolutePath();
        String DIRECTORY_ALARMS_getCanonicalPath = null;
        try {
            DIRECTORY_ALARMS_getCanonicalPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS).getCanonicalPath();
        } catch (IOException e) {
            e.printStackTrace();
        }
        String DIRECTORY_ALARMS_getPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS).getAbsolutePath();

        stringBuilder.append("DIRECTORY_ALARMS_getAbsolutePath\n");
        stringBuilder.append(DIRECTORY_ALARMS_getAbsolutePath);
        stringBuilder.append("\n\n");

        stringBuilder.append("DIRECTORY_ALARMS_getCanonicalPath\n");
        stringBuilder.append(DIRECTORY_ALARMS_getCanonicalPath);
        stringBuilder.append("\n\n");

        stringBuilder.append("DIRECTORY_ALARMS_getPath\n");
        stringBuilder.append(DIRECTORY_ALARMS_getPath);
        stringBuilder.append("\n\n");

        //  /storage/sdcard0/DCIM
        String DIRECTORY_ALARMS =
                Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath();
        //  /storage/sdcard0/DIRECTORY_DOCUMENTS
        String DIRECTORY_DIRECTORY_DOCUMENTS = null;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            DIRECTORY_DIRECTORY_DOCUMENTS = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath();
        }
        //  /storage/sdcard0/Download
        String DIRECTORY_Download = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
        //  /storage/sdcard0/Movies
        String DIRECTORY_Movies = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES).getAbsolutePath();
        // /storage/sdcard0/Music
        String DIRECTORY_Music = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath();
        // /storage/sdcard0/Notifications
        String DIRECTORY_Notifications = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_NOTIFICATIONS).getAbsolutePath();
        //  /storage/sdcard0/Pictures
        String DIRECTORY_Pictures = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath();
        //  /storage/sdcard0/Podcasts
        String DIRECTORY_Podcasts = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PODCASTS).getAbsolutePath();
        // /storage/sdcard0/Ringtones
        String DIRECTORY_Ringtones = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES).getAbsolutePath();


        stringBuilder.append("DIRECTORY_ALARMS\n");
        stringBuilder.append(DIRECTORY_ALARMS);
        stringBuilder.append("\n\n");


        stringBuilder.append("DIRECTORY_DIRECTORY_DOCUMENTS\n");
        stringBuilder.append(DIRECTORY_DIRECTORY_DOCUMENTS);
        stringBuilder.append("\n\n");

        stringBuilder.append("DIRECTORY_Download\n");
        stringBuilder.append(DIRECTORY_Download);
        stringBuilder.append("\n\n");

        stringBuilder.append("DIRECTORY_Movies\n");
        stringBuilder.append(DIRECTORY_Movies);
        stringBuilder.append("\n\n");

        stringBuilder.append("DIRECTORY_Music\n");
        stringBuilder.append(DIRECTORY_Music);
        stringBuilder.append("\n\n");

        stringBuilder.append("DIRECTORY_Notifications\n");
        stringBuilder.append(DIRECTORY_Notifications);
        stringBuilder.append("\n\n");

        stringBuilder.append("DIRECTORY_Pictures\n");
        stringBuilder.append(DIRECTORY_Pictures);
        stringBuilder.append("\n\n");

        stringBuilder.append("DIRECTORY_Podcasts\n");
        stringBuilder.append(DIRECTORY_Podcasts);
        stringBuilder.append("\n\n");

        stringBuilder.append("DIRECTORY_Ringtones\n");
        stringBuilder.append(DIRECTORY_Ringtones);
        stringBuilder.append("\n\n");


        String getDataDirectory = Environment.getDataDirectory().getAbsolutePath();
        String getDownloadCacheDirectory = Environment.getDownloadCacheDirectory().getAbsolutePath();
        String getExternalStorageDirectory = Environment.getExternalStorageDirectory().getAbsolutePath();
//        String data = Environment.getExternalStoragePublicDirectory();
        String getExternalStorageState = Environment.getExternalStorageState();
        String getRootDirectory = Environment.getRootDirectory().getAbsolutePath();
//        int getStorageState = EnvironmentCompat.getStorageState();

        stringBuilder.append("getDataDirectory\n");
        stringBuilder.append(getDataDirectory);
        stringBuilder.append("\n\n");

        stringBuilder.append("getDownloadCacheDirectory\n");
        stringBuilder.append(getDownloadCacheDirectory);
        stringBuilder.append("\n\n");

        stringBuilder.append("getExternalStorageDirectory\n");
        stringBuilder.append(getExternalStorageDirectory);
        stringBuilder.append("\n\n");

        stringBuilder.append("DIRECTORY_Ringtones\n");
        stringBuilder.append(DIRECTORY_Ringtones);
        stringBuilder.append("\n\n");

        stringBuilder.append("getExternalStorageState\n");
        stringBuilder.append(getExternalStorageState);
        stringBuilder.append("\n\n");

        stringBuilder.append("getRootDirectory\n");
        stringBuilder.append(getRootDirectory);
        stringBuilder.append("\n\n");

        stringBuilder.append("=========LogicalInternalStorageTool========\n");
        stringBuilder.append("getDownloadCacheDirectoryPath\n");
        stringBuilder.append(LogicalInternalStorageTool.getDownloadCacheDirectoryPath());
        stringBuilder.append("\n\n");

        stringBuilder.append("getRootDirectoryPath\n");
        stringBuilder.append(LogicalInternalStorageTool.getRootDirectoryPath());
        stringBuilder.append("\n\n");


        stringBuilder.append("getDataDirectoryPath\n");
        stringBuilder.append(LogicalInternalStorageTool.getDataDirectoryPath());
        stringBuilder.append("\n\n");

        stringBuilder.append("getFilesDirPath\n");
        stringBuilder.append(LogicalInternalStorageTool.getFilesDirPath(this));
        stringBuilder.append("\n\n");


        stringBuilder.append("getCacheDirPath\n");
        stringBuilder.append(LogicalInternalStorageTool.getCacheDirPath(this));
        stringBuilder.append("\n\n");


        stringBuilder.append("getFileStreamPath\n");
        stringBuilder.append(LogicalInternalStorageTool.getFileStreamPath(this));
        stringBuilder.append("\n\n");

        stringBuilder.append("getDirPath\n");
        stringBuilder.append(LogicalInternalStorageTool.getDirPath(this));
        stringBuilder.append("\n\n");


        stringBuilder.append("getSharedPreferences\n");
        stringBuilder.append(LogicalInternalStorageTool.getSharedPreferences(this));
        stringBuilder.append("\n\n");


        /*stringBuilder.append("deleteSharedPreferences\n");
        stringBuilder.append(LogicalInternalStorageTool.deleteSharedPreferences(this));
        stringBuilder.append("\n\n");*/

        stringBuilder.append("getDataDir\n");
        stringBuilder.append(LogicalInternalStorageTool.getDataDir(this));
        stringBuilder.append("\n\n");


        stringBuilder.append("getDatabasePath\n");
        stringBuilder.append(LogicalInternalStorageTool.getDatabasePath(this));
        stringBuilder.append("\n\n");

        stringBuilder.append("openFileInput\n");
        stringBuilder.append(LogicalInternalStorageTool.openFileInput(this));
        stringBuilder.append("\n\n");


        stringBuilder.append("fileList\n");
        String[] fileSSSs = LogicalInternalStorageTool.fileList(this);
        for (String file : fileSSSs) {
            stringBuilder.append(file);
            stringBuilder.append("\n\n");
        }

        /*stringBuilder.append("deleteFile\n");
        stringBuilder.append(LogicalInternalStorageTool.deleteFile(this));
        stringBuilder.append("\n\n");*/


        stringBuilder.append("getCodeCacheDir\n");
        stringBuilder.append(LogicalInternalStorageTool.getCodeCacheDirPath(this));
        stringBuilder.append("\n\n");


        stringBuilder.append("getNoBackupFilesDir\n");
        stringBuilder.append(LogicalInternalStorageTool.getNoBackupFilesDirPath(this));
        stringBuilder.append("\n\n");


        stringBuilder.append("========LogicalExternalStorageTool=======\n");
        stringBuilder.append("getPhysicalInternalStoragePath\n");
        stringBuilder.append(LogicalExternalStorageTool.getPhysicalInternalStoragePath(this));
        stringBuilder.append("\n\n");
        stringBuilder.append("getPhysicalExternalStoragePath\n");
        stringBuilder.append(LogicalExternalStorageTool.getPhysicalExternalStoragePath(this));
        stringBuilder.append("\n\n");

        stringBuilder.append("getExternalCacheDirPath\n");
        stringBuilder.append(LogicalExternalStorageTool.getExternalCacheDirPath(this));
        stringBuilder.append("\n\n");

        stringBuilder.append("getExternalFilesDirPath\n");
        stringBuilder.append(LogicalExternalStorageTool.getExternalFilesDirPath(this));
        stringBuilder.append("\n\n");

        stringBuilder.append("getExternalFilesDirPath_DirectoryDownloads\n");
        stringBuilder.append(LogicalExternalStorageTool.getExternalFilesDirPath_DirectoryDownloads(this));
        stringBuilder.append("\n\n");

        stringBuilder.append("getExternalStorageDirectoryPath\n");
        stringBuilder.append(LogicalExternalStorageTool.getExternalStorageDirectoryPath());
        stringBuilder.append("\n\n");

        stringBuilder.append("getExternalStoragePublicDirectory_DirectoryDownloads\n");
        stringBuilder.append(LogicalExternalStorageTool.getExternalStoragePublicDirectory_DirectoryDownloads());
        stringBuilder.append("\n\n");


        stringBuilder.append("getExternalMediaDirs\n");
        File[] files = LogicalExternalStorageTool.getExternalMediaDirs(this);
        for (File file : files) {
            stringBuilder.append(file.getAbsolutePath());
            stringBuilder.append("\n\n");
        }

        stringBuilder.append("getObbDirPath\n");
        stringBuilder.append(LogicalExternalStorageTool.getObbDirPath(this));
        stringBuilder.append("\n\n");


        stringBuilder.append("isPhysicalExternalStorageWritable\n");
        stringBuilder.append(LogicalExternalStorageTool.isPhysicalExternalStorageWritable(this,
                LogicalExternalStorageTool.getExternalStorageDirectoryPath()));
        stringBuilder.append("\n\n");

        stringBuilder.append("isPhysicalExternalStorageReadable\n");
        stringBuilder.append(LogicalExternalStorageTool.isPhysicalExternalStorageReadable(this,
                LogicalExternalStorageTool.getExternalStorageDirectoryPath()));
        stringBuilder.append("\n\n");

        stringBuilder.append("isExternalStorageWritable\n");
        stringBuilder.append(LogicalExternalStorageTool.isExternalStorageWritable());
        stringBuilder.append("\n\n");

        stringBuilder.append("isExternalStorageReadable\n");
        stringBuilder.append(LogicalExternalStorageTool.isExternalStorageReadable());
        stringBuilder.append("\n\n");

        id_dev.setText(stringBuilder.toString());
    }
}
